﻿<Window x:Class="ResourceBlender_Express.WinAddElement"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:loc="clr-namespace:ResourceBlender_Express"
    xmlns:validators="clr-namespace:ResourceBlender_Express.Validators"
    loc:WindowService.EscapeClosesWindow="True"
    Title="Add Element" 
    MinHeight="310" MinWidth="380" Height="310" Width="400"
    SizeToContent="Height" WindowStartupLocation="CenterOwner"
    Style="{StaticResource {x:Type Window}}" Icon="/ResourceBlender-Express;component/Resources/images/resourceblender.ico">
    <Window.CommandBindings>
        <CommandBinding Command="loc:ResourceBlenderCommands.OpenFullEditor" Executed="ShowFullEditor" />
        <CommandBinding Command="loc:ResourceBlenderCommands.FindSimilar" Executed="FindSimilar" />
        <CommandBinding Command="loc:ResourceBlenderCommands.ExpandAll" Executed="ExpandAll" />
        <CommandBinding Command="ApplicationCommands.Save" Executed="Save" />
        <CommandBinding Command="ApplicationCommands.Close" Executed="CloseWindow" />
    </Window.CommandBindings>
    <Window.Resources>

    </Window.Resources>
    <DockPanel>
        <ToolBar x:Name="tlbMain" DockPanel.Dock="Top" VerticalAlignment="Top" HorizontalAlignment="Stretch" IsHitTestVisible="True" HorizontalContentAlignment="Left">
            <loc:ImageButton Command="ApplicationCommands.Save" IsDefault="True" Text="Save" ToolTip="Save and Close" ShowText="False" Image="Resources/images/save_24.png" Style="{StaticResource ToolBarButton}" />
            <!--loc:ImageButton Command="OpenPOEditor" Text="OpenPOEditor" Image="Resources/images/applications_32.png" ToolTip="Save and Close" />
            <Button x:Name="btnSave" MinWidth="70" Click="btnSave_Click">Save</Button>
            <Button x:Name="btnCancel" MinWidth="70" IsCancel="True" Click="btnCancel_Click" Margin="2,2,0,2">Cancel</Button-->
        </ToolBar>
        <Grid DockPanel.Dock="Top" Margin="6">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>

            <Label Grid.Row="0" Grid.Column="0">Element Name</Label>
            <TextBox Grid.Row="0" Grid.Column="1" Grid.ColumnSpan="2" x:Name="txtElement">
                <Binding Path="Name" Mode="TwoWay">
                    <Binding.ValidationRules>
                        <validators:StringValidationRule MinimumLength="0" MaximumLength="255" ErrorMessage="Element name must be between 1 and 255 characters" />
                    </Binding.ValidationRules>
                </Binding>
            </TextBox>
            
            <Label Grid.Row="1" Grid.Column="0" ToolTip="Comments about the element. Eg: Where it's used">Comment</Label>
            <TextBox Grid.Row="1" Grid.Column="1" x:Name="txtComment" Text="{Binding Path=Comment,Mode=TwoWay}" />
            <loc:ImageButton Grid.Row="1" Grid.Column="2" Image="Resources/images/expand_16.png" ShowText="False" ToolTip="Edit this field using the full editor" Margin="1,1,0,1"
                               Command="loc:ResourceBlenderCommands.OpenFullEditor" CommandTarget="{Binding ElementName=txtComment}" />
                    
            <Label Grid.Row="2" Grid.Column="0">Bundle</Label>
            <ComboBox Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="2" x:Name="cboBundle" DisplayMemberPath="Value" SelectedValue="{Binding BundleID,Mode=TwoWay}" SelectedValuePath="Key"></ComboBox>
            
            <Label Grid.Row="3" Grid.Column="0">Resource</Label>
            <ComboBox Grid.Row="3" Grid.Column="1" Grid.ColumnSpan="2" x:Name="cboResource" DisplayMemberPath="Value" SelectedValue="{Binding Resource.ID,Mode=OneWay}" SelectedValuePath="Key" SelectionChanged="cboBundle_SelectionChanged"></ComboBox>
            
            <Label Grid.Row="4" Grid.Column="0" ToolTip="Comments about the element. Eg: Where it's used">Resource Comment</Label>
            <TextBox Grid.Row="4" Grid.Column="1" x:Name="txtResourceComment" Text="{Binding Path=Resource.Comment,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" />
            <loc:ImageButton Grid.Row="4" Grid.Column="2" Image="Resources/images/expand_16.png" ShowText="False" ToolTip="Edit this field using the full editor" Margin="1,1,0,1"
                               Command="loc:ResourceBlenderCommands.OpenFullEditor" CommandTarget="{Binding ElementName=txtComment}" />
            
            <loc:TranslationInput Grid.Row="5" Grid.Column="0" Grid.ColumnSpan="3" x:Name="defaultLanguageInput" /><!-- ValidationRule added in codebehind -->
            
            <Expander Grid.Row="6" Grid.Column="0" Grid.ColumnSpan="3" x:Name="expTranslations" Header="Translations" Margin="0,4,0,2">
                <ScrollViewer VerticalScrollBarVisibility="Auto" Height="350" MaxHeight="500" HorizontalContentAlignment="Stretch">
                    <StackPanel HorizontalAlignment="Stretch">
                        <Button Command="loc:ResourceBlenderCommands.ExpandAll" MinWidth="140" HorizontalAlignment="Left">Expand All Translations</Button>
                        <StackPanel x:Name="stkTranslations" />
                    </StackPanel>
                </ScrollViewer>
            </Expander>
        </Grid>
        <StatusBar DockPanel.Dock="Bottom" Height="24">
            <StatusBarItem x:Name="lblStatus" Visibility="Hidden">Loading</StatusBarItem>
            <ProgressBar x:Name="prgStatus" IsIndeterminate="True" Visibility="Hidden" />
        </StatusBar>
    </DockPanel>
</Window>
